1 using UnityEngine;
2 using
System.Collections;
3
4 public
class Bonus : MonoBehaviour
5 {
6     
public BonusesEnum thisBonus;
7     
public Material[] materials;
8     
public Renderer rend;
9     
public Random random;
10
11     
void Awake ()
12     {
13         rend = GetComponent<Renderer>();
14         random =
new Random();
15     }
16
17     
//0 - health, 1 - money, 2 - speed, 3 - bullet
18     
void RandomizeBonus()
19     {
20         
int r = random.Randomization_1(0, 10, 50, 80, 99);
21         thisBonus = (BonusesEnum)r;
22         rend.sharedMaterial = materials[r];
23     }
24
25     
public void Activation(Vector3 revealPosition)
26     {
27         transform.position = revealPosition;
28         RandomizeBonus();
29     }
30
31     
void OnTriggerExit(Collider col)
32     {
33         
if (col.tag == "SpawnBorders")
34         {
35             BonusIsOff();
36         }
37     }
38
39     
void BonusIsOff()
40     {
41         transform.gameObject.SetActive(
false);
42     }
43 }


0 - health, 1 - money, 2 - speed, 3 - bullet




Trò chơi game bắn súng đơn giản trong UNITY Engine 23.606 lượt xem

Gõ tìm kiếm nhanh...